using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DSLights : MonoBehaviour
{
	public List<UISprite> lights = new List<UISprite>();

	public float lowAlpha;

	private bool initialized_;

	private void Init()
	{
		if (!initialized_)
		{
			base.gameObject.SetActive(false);
			initialized_ = true;
		}
	}

	public void SetColor(Color col)
	{
		foreach (UISprite light in lights)
		{
			col.a = light.color.a;
			light.color = col;
		}
	}

	public void ShowLights()
	{
		base.gameObject.SetActive(true);
		StopAllCoroutines();
		StartCoroutine(DoShowLights());
	}

	private IEnumerator DoShowLights()
	{
		int lightIndex = 0;
		float duration = 0.25f;
		float time2 = 0f;
		while (true)
		{
			foreach (UISprite light in lights)
			{
				light.alpha = lowAlpha;
			}
			time2 = 0f;
			while (time2 <= duration)
			{
				time2 += Time.deltaTime;
				lights[lightIndex].alpha = Mathf.Lerp(lowAlpha, 1f, Mathf.PingPong(time2 / duration, 1f));
				yield return null;
			}
			lightIndex = (lightIndex + 1) % lights.Count;
		}
	}
}
